package com.graduate.after.service.impl;

import com.graduate.after.bean.DetailBaseData;
import com.graduate.after.bean.DetailComment;
import com.graduate.after.bean.DetailDescript;
import com.graduate.after.bean.DetailParams;
import com.graduate.after.mapper.DetailDataMapper;
import com.graduate.after.service.DetailDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class DetailDataServiceImpl implements DetailDataService {

    @Autowired
    private DetailDataMapper detailDataMapper;

    @Override
    public DetailBaseData detailBaseDataSelect(Long iid) {
        DetailBaseData detailBaseData = detailDataMapper.detailBaseDataSelect(iid);
        return detailBaseData;
    }

    @Override
    public List<DetailDescript> detailScenicSelect(Long iid) {
        List<DetailDescript> detailDescripts = detailDataMapper.detailScenicDescriptSelect(iid);
        return detailDescripts;
    }

    @Override
    public List<DetailDescript> detailHistorySelect(Long iid) {
        List<DetailDescript> detailDescripts = detailDataMapper.detailHistoryDescriptSelect(iid);
        return detailDescripts;
    }

    @Override
    public List detailParamsSelect(Long iid) {
        DetailParams detailParams = detailDataMapper.detailParamsSelect(iid);
        List list = new ArrayList();
        if(!Objects.isNull(detailParams)) {
            if(detailParams.getChina_name() != null) {list.add(new DetailParams("中文名:",detailParams.getChina_name()));}
            if(detailParams.getForeign_name() != null) {list.add(new DetailParams("外文名:",detailParams.getForeign_name()));}
            if(detailParams.getGeographic_location() != null) {list.add(new DetailParams("地理位置:",detailParams.getGeographic_location()));}
            if(detailParams.getClimatic_conditions() != null) {list.add(new DetailParams("气候条件:",detailParams.getClimatic_conditions()));}
            if(detailParams.getOpen_time() != null) {list.add(new DetailParams("开放时间:",detailParams.getOpen_time()));}
            if(detailParams.getScenic_level() != null) {list.add(new DetailParams("景点级别:",detailParams.getScenic_level()));}
            if(detailParams.getRates() != null) {list.add(new DetailParams("门票价格:",detailParams.getRates()));}
            if(detailParams.getFamous_scenery() != null) {list.add(new DetailParams("著名景点:",detailParams.getFamous_scenery()));}
            if(detailParams.getMain_peak() != null) {list.add(new DetailParams("主峰:",detailParams.getMain_peak()));}
            if(detailParams.getHome_country() != null) {list.add(new DetailParams("所属国家:",detailParams.getHome_country()));}
            if(detailParams.getHome_city() != null) {list.add(new DetailParams("所属城市:",detailParams.getHome_city()));}
            if(detailParams.getSuggest_time() != null) {list.add(new DetailParams("建议游玩时长:",detailParams.getSuggest_time()));}
            if(detailParams.getSuggest_season() != null) {list.add(new DetailParams("适宜游玩季节:",detailParams.getSuggest_season()));}
        }

        return list;
    }

    @Override
    public List<DetailComment> detailCommentSelect(Long iid) {
        List<DetailComment> detailComments = detailDataMapper.detailCommentSelect(iid);
        return detailComments;
    }
}
